home *** CD-ROM | disk | FTP | other *** search
Wrap
Oberon Document | 1996-09-29 | 2.4 KB | 65 lines | [ BINA/hDmp]
Documents.StdDocumentDesc Documents.DocumentDesc Containers.ViewDesc Views.ViewDesc Stores.StoreDesc Documents.ModelDesc Containers.ModelDesc Models.ModelDesc Stores.ElemDesc TextViews.StdViewDesc TextViews.ViewDesc TextModels.StdModelDesc TextModels.ModelDesc TextModels.AttributesDesc Helvetica (* This Module is a sample using the Oberon/F framework. It performs a ROT-13 on the current text selection. This module can be added to any program that uses the text subsystem. PROCEDURE Do is a parameterless procedure called a "command" . This is a complete module and can be compiled by iteself. *) MODULE MactechRot13; IMPORT Models, TextModels, TextControllers, Domains; PROCEDURE Do*; VAR tc: TextControllers.Controller; beg, end: LONGINT; tr: TextModels.Reader; ch: CHAR; buf: TextModels.Model; tw: TextModels.Writer; script: Domains.Operation; BEGIN tc := TextControllers.Focus(); IF (tc # NIL) & tc.HasSelection() THEN tc.GetSelection(beg, end); buf := TextModels.Clone(tc.text); tw :=buf.NewWriter(NIL); tr := tc.text.NewReader(NIL); tr.SetPos(beg); tr.ReadChar(ch); WHILE (tr.Pos() <= end) & ~tr.eot DO IF ((ch >= "a") & (ch <= "m")) OR ((ch >= "A") & (ch <= "M")) THEN ch := CHR(ORD(ch)+13); ELSIF ((ch >= "n") & (ch <= "z")) OR ((ch >= "N") & (ch <= "Z")) THEN ch := CHR(ORD(ch)-13) END; tw.WriteChar(ch); tr.ReadChar(ch) END; Models.BeginScript(tc.text, "Rot13", script); tc.text.Delete(beg, end); tc.text.CopyFrom(beg, buf, 0, end - beg); Models.EndScript(tc.text, script) END END Do; END MactechRot13. TextControllers.StdCtrlDesc TextControllers.ControllerDesc Containers.ControllerDesc Controllers.ControllerDesc TextRulers.StdRulerDesc TextRulers.RulerDesc TextRulers.StdStyleDesc TextRulers.StyleDesc TextRulers.AttributesDesc Helvetica Documents.ControllerDesc